package backend

import (
	"gin_demo/internal/controller/backend/admin"
	"gin_demo/internal/controller/backend/category"
	"gin_demo/internal/controller/backend/login"
	"gin_demo/internal/controller/backend/orders"
	"gin_demo/internal/controller/backend/permission"
	"gin_demo/internal/controller/backend/role"
	"gin_demo/internal/controller/backend/rotation"
	"gin_demo/internal/controller/refresh"
	"gin_demo/internal/controller/upload"

	"gin_demo/internal/middleware"

	"github.com/gin-gonic/gin"
)

func BackendRouter(router *gin.RouterGroup) {
	router.POST("/login", login.CLogin.Login)
	rot := router.Group("/rotation", middleware.CheckToken())
	{
		rot.GET("list", rotation.Rotaion.List)
		rot.POST("add", rotation.Rotaion.Create)
		rot.DELETE("del", rotation.Rotaion.Delete)
		rot.PUT("update", rotation.Rotaion.Update)
	}
	ad := router.Group("/admin", middleware.CheckToken())
	{
		ad.POST("add", admin.Admin.Create)
		ad.GET("list", admin.Admin.List)
		ad.DELETE("del", admin.Admin.Delete)
		ad.PUT("update", admin.Admin.Update)
	}
	ca := router.Group("/category", middleware.CheckToken())
	{
		ca.GET("list", category.Category.List)
		ca.POST("add", category.Category.Create)
		ca.DELETE("del", category.Category.Delete)
		ca.PUT("update", category.Category.Update)
	}
	ro := router.Group("/role", middleware.CheckToken())
	{
		ro.POST("add", role.SRole.Create)
		ro.GET("list", role.SRole.List)
		ro.DELETE("del", role.SRole.Delete)
		ro.PUT("update", role.SRole.Update)
		ro.POST("create_role_permission", role.SRole.CreadRolePermission)
		ro.GET("role_permission", role.SRole.RolePermission)
		ro.PUT("updaterolepermission", role.SRole.UpdateRolePermission)
		ro.DELETE("del_role_permission", role.SRole.DeleteRolePermission)
	}
	pe := router.Group("/permission", middleware.CheckToken())
	{
		pe.POST("add", permission.SPermission.Create)
		pe.GET("list", permission.SPermission.List)
		pe.DELETE("del", permission.SPermission.Delete)
		pe.PUT("update", permission.SPermission.Update)
	}
	order := router.Group("/order", middleware.CheckToken())
	{
		order.POST("add", orders.ORder.Create)
		order.GET("list", orders.ORder.List)
		order.DELETE("del", orders.ORder.Delete)
		order.PUT("update", orders.ORder.Update)
		order.GET("search", orders.ORder.Search)
	}

	router.POST("upload_file", middleware.CheckToken(), upload.UPload.UploadFile)
	router.GET("/refresh", middleware.CheckToken(), refresh.REfresh.Refresh)
}
 